<template>
  <div class="closing">
    <div>
      <el-button size="mini" @click="handleGetUntreated">{{ $t('btn.reload') }}</el-button>
      <!--      <el-button type="primary" size="mini" @click="isClosingDialog=true">{{ $t('market.filter') }}&lt;!&ndash;过滤&ndash;&gt;</el-button>-->
    </div>
    <div class="header-name">
      <search
        :options="selectData"
        :search-son="searchSon"
        :msg="tacitly"
        @seek="collect"
        @hand="handleGetUntreated"
      />
      <el-button type="primary" class="btn" size="mini" @click="handleGetUntreated">{{ $t('btn.search') }}</el-button>
    </div>
    <div class="table-content">
      <jc-table
        v-loading="loading"
        :table-data="tableData"
        :table-header="tableHeader"
        :table-height="tableHeight"
        serial
        sortable
      >
        <template v-slot:billSlot="col">
          <el-link type="primary" @click="pushView(col.scope.row)">{{ col.scope.row.fnumber }}</el-link>
        </template>
      </jc-table>
      <div class="footer">
        <jc-pagination
          v-show="total > 0"
          :total="total"
          :page.sync="currentPage"
          :limit.sync="size"
          @pagination="handleGetUntreated"
        />
      </div>
    </div>
  </div>
</template>

<script>
import {
  queryProjectMaterialList
} from '@/api/production/process'
import search from '@/components/Search'
import searData from '@/components/Search/mixin'

export default {
  name: 'BomAutomaticalist',
  components: {
    search
  },
  mixins: [searData],
  data() {
    return {
      ftype: '90',
      total: 0,
      currentPage: 1,
      size: 200,
      loading: false,
      // 表头
      tableData: [], // 销售数据
      tableHeight: '70vh',
      tableHeader: [
        { label: this.$t('market.theName'), prop: 'fname' },
        { label: this.$t('market.odd'), type: 'bill', prop: 'fnumber' },
        { label: this.$t('shop.specifica'), prop: 'fspecification' },
        { label: this.$t('market.model1'), prop: 'fmodel' },
        { label: this.$t('market.creator'), prop: 'fcreator' },
        { label: this.$t('market.createDate'), prop: 'fcreatedate' }
      ]
    }
  },
  created() {
    this.handleGetUntreated()
    this.tableHeight = window.innerWidth > 1440 ? 'calc(100vh - 230px)' : '73vh'
  },
  methods: {
    // 获取工程BOM算料列表数据
    async handleGetUntreated() {
      this.loading = true
      const DATA = {
        pageNum: this.currentPage,
        pageSize: this.size
      }
      const RES = await queryProjectMaterialList(DATA)
      if (RES.code === 0) {
        this.loading = false
        this.tableData = RES.data.array
        this.total = RES.data.total
      } else {
        this.loading = false
        this.$confirm(RES.message, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'error'
        })
      }
    },
    // 跳转详情
    pushView(ev) {
      this.$router.push({ path: `/bomAutomatDetail/${ev.fid}` })
    },
    // 搜索
    handleQuerySonClass() {
      this.currentPage = 1
      this.handleGetUntreated()
    }
  }
}
</script>
<style lang="scss" scoped>
.closing {
  @include listBom;
  .el-input::v-deep .el-input__inner {
    height: 30px;
    line-height: 30px;
  }
  .header-name{
    position: relative;
    margin-bottom: 10px;
    .btn {
      transform: translateY(18%);
      margin-left: 450px;
    }
  }
}
</style>
